
<?php
error_reporting(E_ALL);
$user_email = $_GET["user_email"];
$con = mysqli_connect("localhost","davidjwa_hack","hackathon16","davidjwa_hack");
// Check connection


if (mysqli_connect_errno())
{
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$result = mysqli_query($con,"SELECT * FROM contacts WHERE user_email = '$user_email' ");
echo "<html>";
//echo "<form name=\"input\" action=\"alter-contact.php\" method=\"post\"><br />";
$num=mysqli_num_rows($result);
//var_dump($result);
while($row = mysqli_fetch_array($result)) {

    echo "First Name:<input type=\"text\" name=\"fname\" value=". $row["fname"] ."><br />";
    echo "Surname: <input type=\"text\" name=\"sname\" value=". $row['sname']."><br />";
    echo "Title: <input type=\"text\" name=\"title\" value=". $row['title']."><br />";
    echo "Type: <input type=\"text\" name=\"type\" value=". $row['type']."><br />";
    echo "Phone number: <input type=\"text\" name=\"phonenumber\" value=". $row['pnumber1']."><br />";
    echo "Contact email: <input type=\"text\" name=\"contact_email\" value=". $row['contact_email']."><br />";
    echo "Address: <input type=\"text\" name=\"address\" value=". $row['address']."><br />";
    echo "ICE:  <select name=\"ice\" value=". $row['ice'].">
<option value=\"1\">Ice</option>
<option value=\"2\">Main Ice</option>
<option value=\"0\">Not Ice</option>
</select><br/>   ";
    echo "<input type=\"hidden\" name=\"orig_email\" value=". $row['user_email']."><br />";
    echo "<input type=\"submit\" value=\"update\"><br/>";
}
echo "<input type=\"hidden\" name=\"no_rowsl\" value=". $num."><br />";

echo "</form>";
echo "</html>";
mysqli_close($con);